<?php
namespace app\admin\model\menu;
use think\Model;
use think\Db;
use app\admin\common;
class Menu extends Model {
	private $table_obj;
	
	public function selectMenu($where,$field='*',$order){
		extract(common::get('menu',[$where,$field,$order,__function__]));
		if(empty($data)){
			$menu=new Menu;
			$data=$menu::where($where)->field($field)->order($order)->select();
			common::set($data);
		}
		return $data->toArray();
	}
	/**
	 * 插入数据
	 * 
	 */
	public function insertMenuData($data){
		common::delete("menu");
		$admin=new Menu;
		$admin->save($data);
		return $admin->id;
	}
	/**
	 * 更新数据
	 */
	public function updateMenuData($up,$where){
		common::delete("menu");
		$admin=Menu::find($where);
		$r=$admin->save($up);
		return $r;
	}
	
	public function selectMenuData($where,$order,$limit){
		extract(common::get('menu',[$where,$order,$limit,__function__]));
		if(empty($data)){
			$data=Menu::where($where)->limit(current($limit),next($limit))->order($order)->select();
			common::set($data);
		}
		return $data->toArray();
	}
}
?>